package com.ztgf.shopping.api.client.shop;

import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.shopping.models.service.shop.IShopOnlineService;
import com.ztgf.shopping.models.vo.shop.ShopImResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/shopOnlineApi")
@Api(value = "ShopOnlineApiController", tags = "店铺在线时长API")
public class ShopOnlineApiController {

    @DubboReference
    private IShopOnlineService shopOnlineService;

    @PostMapping(value = "/addOnShopId")
    @ApiOperation(value = "根据店铺id新增记录", notes = "根据店铺id新增记录")
    public Result<?> addOnShopId(Long shopId) {
        shopOnlineService.addOnShopId(shopId);
        return new Result<>(CodeEnum.SUCCESS);
    }

    @PostMapping(value = "/updateShopOutTime")
    @ApiOperation(value = "修改用户退出登录时间", notes = "修改用户退出登录时间")
    public Result<?> updateShopOutTime(Long shopId) {
        shopOnlineService.updateShopOutTime(shopId);
        return new Result<>(CodeEnum.SUCCESS);
    }

    @PostMapping(value = "/getShopImState")
    @ApiOperation(value = "测试获取店铺im状态", notes = "修改用户退出登录时间")
    public Result<?> getShopImState(Long shopId) {
        ShopImResponseVO response = shopOnlineService.getShopImState(shopId);
        return new Result<>(response);
    }
}
